package com.cweb.admin.model.sys.sys_menu_info.controller;


import com.cweb.admin.model.sys.sys_menu_info.entity.SysMenuInfo;
import com.cweb.admin.model.sys.sys_menu_info.service.SysMenuInfoService;
import com.cweb.framework.annotation.Remark;
import com.cweb.framework.base.controller.BaseController;
import com.cweb.framework.pojo.BaseResponse;
import com.cweb.framework.pojo.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统-系统菜单信息表 前端控制器
 *
 * @author changfan
 */
@RestController
@RequestMapping("sys/menu")
public class SysMenuInfoController extends BaseController {
    @Autowired
    SysMenuInfoService sysMenuInfoService;

    /**
     * 菜单查询
     */
    @RequestMapping("get")
    @Remark(name = "查询用户的菜单", describe = "")
    public BaseResponse get() throws CustomException {
        return new BaseResponse(sysMenuInfoService.selectMenu(false));
    }

    /**
     * 菜单查询(全部)
     */
    @RequestMapping("all")
    @Remark(name = "查询全部", describe = "")
    public BaseResponse all() throws CustomException {
        return new BaseResponse(sysMenuInfoService.selectMenu(true));
    }

    @ResponseBody
    @RequestMapping("add")
    @Remark(name = "新增", describe = "")
    public BaseResponse add(SysMenuInfo param) throws CustomException {
        return new BaseResponse(sysMenuInfoService.save(param));
    }

    @ResponseBody
    @RequestMapping("change")
    @Remark(name = "更新", describe = "")
    public BaseResponse change(SysMenuInfo param) throws CustomException {
        return new BaseResponse(sysMenuInfoService.updateById(param));
    }

    @ResponseBody
    @RequestMapping("delete")
    @Remark(name = "删除", describe = "")
    public BaseResponse delete(SysMenuInfo param) throws CustomException {
        sysMenuInfoService.removeById(param.getId());
        return new BaseResponse();
    }
}

